
function selectMerchandiseType(merchandise_type_id){
	var url = '/storage/manager/pages/merchandiseType.do?method=selectMerchandiseType&d=' + new Date();
	url = url + '&merchandise_type_id_val='+merchandise_type_id;

	$.getJSON(url, {}, function(data){
		var merchandise_type_id = document.getElementById('merchandise_type_id');
		var parent_type = document.getElementById('parent_type');
		var merchandise_type_name = document.getElementById('merchandise_type_name');
		
		setTimeout(function (){
			merchandise_type_id.value = data[0][0];
			merchandise_type_name.value = data[0][1];
			parent_type.value = data[0][2];
		},500);
	});
};
function saveOrUpdate(){
	var merchandise_type_id = document.getElementById('merchandise_type_id').value;
	
	var isFull = true;
	
	if(isFull){
		merchandise_type_id==''?save():update();
	}else{
		alert('必要信息不完整');
	}
};
function save(){
	var parent_type_val = escape(escape(document.getElementById('parent_type').value));
	var merchandise_type_name_val = escape(escape(document.getElementById('merchandise_type_name').value));

	var url = '/storage/manager/pages/merchandiseType.do?method=create&d=' + new Date();
	url = url + '&parent_type_val='+parent_type_val;
	url = url + '&merchandise_type_name_val='+merchandise_type_name_val;
	
	$.getJSON(url, {}, function(data){
		if(data=="true"){
			alert("保存成功");
			window.close();
		}else{
			alert("保存失败");
		}
	});
};
function update(){
	var merchandise_type_id_val = escape(escape(document.getElementById('merchandise_type_id').value));
	var parent_type_val = escape(escape(document.getElementById('parent_type').value));
	var merchandise_type_name_val = escape(escape(document.getElementById('merchandise_type_name').value));
	
	var url = '/storage/manager/pages/merchandiseType.do?method=update&d=' + new Date();
	url = url + '&merchandise_type_id_val='+merchandise_type_id_val;
	url = url + '&parent_type_val='+parent_type_val;
	url = url + '&merchandise_type_name_val='+merchandise_type_name_val;

	$.getJSON(url, {}, function(data){
		if(data=="true"){
			alert("更新成功");
			window.close();
		}else{
			alert("更新失败");
		}
	});
};